package com.cwf.admin.web.controller.system;


import com.cwf.common.entity.http.R;
import com.cwf.framework.authcode.entity.KaptchaImageCodeEntity;
import com.cwf.framework.authcode.service.KaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/api/auth/code")
public class KaptchaController {


    @Autowired
    private KaptchaService kaptchaService;
    
    
    /**
     * @description 获取图形验证码
     * @author 18068
     * @date 2023/2/17 11:27
     * @return 
     */
    @RequestMapping("/image")
    public R generateImageCode(){
        try {
            KaptchaImageCodeEntity codeEntity = kaptchaService.generateImageCode();
            return R.success(codeEntity);
        } catch (IOException e) {
            return R.error("获取验证码失败");
        }
    }
}
